import * as types from '../constants/ActionTypes';

const initialState = {
  carInfo: {},
  dealerInfo: {},
  driveBill: {},
  priceBill: {},
  carBrands: [],
  subBrand: {},
  carModels: [],
  carModel: {},
  carStyles: [],
  compare: {},
  recommendCar: {},
  compareCar: {},
  name: '', // 修改价格单信息
  phone: '',
  sex: '',
  address: '',
  counselor: '',
};

const CommunicateReducer = (state = initialState, action) => {
  switch (action.type) {
    case types.CAR_INFO:
      return ({ ...state,
        ...{
          carInfo: action.carInfo,
        } });
    case types.GET_DEALER_INFO:
      return ({ ...state,
        ...{
          dealerInfo: action.dealerInfo,
        } });
    case types.DRIVE_BILL:
      return ({ ...state,
        ...{
          driveBill: action.driveBill,
        } });
    case types.PRICE_BILL:
      return ({ ...state,
        ...{
          priceBill: action.priceBill,
        } });
    case types.CAR_BRAND:
      return ({ ...state,
        ...{
          carBrands: action.carBrands,
        } });
    case types.SUB_BRAND:
      return ({ ...state,
        ...{
          subBrand: action.subBrand,
        } });
    case types.CAR_MODEL:
      return ({ ...state,
        ...{
          carModels: action.carModels,
        } });
    case types.MODEL:
      return ({ ...state,
        ...{
          carModel: action.carModel,
        } });
    case types.CAR_STYLE:
      return ({ ...state,
        ...{
          carStyles: action.carStyles,
        } });
    case types.STYLE:
      return ({ ...state,
        ...{
          carStyle: action.carStyle,
        } });
    case types.COMPARE_CAR:
      return ({ ...state,
        ...{
          compare: action.compare,
        } });
    case types.RECOMMEND_CAR:
      return ({ ...state,
        ...{
          recommendCar: action.recommendCar,
        } });
    case types.SELECT_COMPARE_CAR:
      return ({ ...state,
        ...{
          compareCar: action.compareCar,
        } });
    case types.MODIFY_PRICE:
      return ({ ...state,
        ...{
          name: action.name,
          phone: action.phone,
          sex: action.sex,
          address: action.address,
          counselor: action.counselor,
        } });
    default:
      return state;
  }
};

export default CommunicateReducer;
